package com.xmkj.bearbiz.pk.adaper;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.common.BearBean.CommuniBean;
import com.common.widget.imageview.image.ImageLoaderUtils;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearbiz.R;
import com.xmkj.bearbiz.pk.ContentDetailsActivity;

import java.util.List;

/**
 * Create by leo
 * 创建日期：2018/7/28
 * 描述：
 */

public class ChenLieAdapter extends CommonAdapter<CommuniBean.CollocationEntity> {
    public ChenLieAdapter(Context context, List<CommuniBean.CollocationEntity> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, final CommuniBean.CollocationEntity item, int position) {
//        holder.setImageStr(R.id.iv_img, item.pic_url);
        ImageView ivImg  = holder.getView(R.id.iv_img);
        ImageLoaderUtils.displayAllImg(ivImg,item.pic_url);
        holder.setText(R.id.tv_title, item.title);
        holder.setText(R.id.tv_content,item.content_abbreviate);
        holder.setText(R.id.tv_date,item.date);
        holder.getParentView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, ContentDetailsActivity.class);
                intent.putExtra(ContentDetailsActivity.ACTIVITY_ID, item.activity_id + "");
                mContext.startActivity(intent);
            }
        });
    }

    @Override
    protected int getItemViewLayoutId(int position, CommuniBean.CollocationEntity item) {
        return R.layout.item_tuisong;
    }
}
